package com.dust.yuheadline.common.exception;

import com.dust.yuheadline.common.utils.ResponseCode;
import lombok.Getter;

/**
 * 自定义异常
 *
 * @author 高翔宇
 * @since 2024-04-30, 周二, 15:18
 */
@Getter
public class CustomException extends RuntimeException {
    private final int errorCode;
    private final String errorMessage;

    @SuppressWarnings("unused")
    public CustomException(int errorCode, String errorMessage) {
        super(errorMessage);
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public CustomException(ResponseCode responseCode) {
        super(responseCode.getMessage());
        this.errorCode = responseCode.getCode();
        this.errorMessage = responseCode.getMessage();
    }
}